package co.com.ejb.security;
/**
 * Represents a school holding doors which may be
 * opened by various users. Using the EJB Security model,
 * access to open a particular door may be blocked
 * to certain users.
 *
 * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
 * @version $Revision: $
 */
public interface SecureSchoolLocalBusiness
{
	/**
	 * Opens the school for business. At this point the
	 * front door will be unlocked for all.
	 * This method may only be called by users in role
	 * {@link Roles#ADMIN}.
	 */
	void open();
	/**
	 * Closes the school for business. At this point the
	 * front door will be locked for all but users
	 * in role {@link Roles#ADMIN}
	 * This method may only be called by admins.
	 */
	void close();
	/**
	 * Opens the front door. While school is open,
	 * any authenticated user may open the door, else
	 * only the {@link Roles#ADMIN} may open.
	 *
	 * @throws SchoolClosedException If the current user
	 * is not in {@link Roles#ADMIN} and is attempting to open
	 * the door while {@link SecureSchoolLocalBusiness#isOpen()}
	 * is false.
	 */
	void openFrontDoor() throws SchoolClosedException;
	/**
	 * Opens the service door. Users in {@link Roles#STUDENT}
	 * role may not open this door, but {@link Roles#ADMIN}
	 * and {@link Roles#JANITOR} may.
	 */
	void openServiceDoor();
	/**
	 * Returns whether or not the school is open. When closed, only
	 * the {@link Roles#ADMIN} is allowed access to all doors. Anyone,
	 * even unauthenticated users, may check if school is open.
	 * @return
	 */
	boolean isOpen();
}